/**
 * 项目名称:
 *
 * @Author: 夏国倩
 * @Date: 2023/10/12 10:23
 * @Copyright
 */
package multithreading;
/*
线程优先级高的获取CPU的时间片相对多一些
优先级 1~10
最低是 1
最高是 10
默认是 5
 */
public class ThreadTest5 {
    public static void main(String[] args) {
        System.out.println(Thread.MAX_PRIORITY); //10
        System.out.println(Thread.MIN_PRIORITY); //1
        System.out.println(Thread.NORM_PRIORITY); //5
        //创建线程
        Thread t1=new Processor5();
        t1.setName("t1");

        Thread t2=new Processor5();
        t2.setName("t2");

        System.out.println(t1.getPriority()); //5
        System.out.println(t1.getPriority()); //5

        //设置优先级
        t1.setPriority(5);
        t2.setPriority(6);

        //启动线程
        t1.start();
        t2.start();
    }
}
class  Processor5 extends Thread{
    public void run(){
        for (int i = 0; i < 50; i++) {
            System.out.println(Thread.currentThread().getName()+"---->"+i);
        }
    }
}
